<?php
	include("../connect.php");
	
/*	$tim = $_REQUEST['tim'];
	$ms_muc_tin = $_REQUEST['muc_t'];*/
	
	mysql_query("SET character_set_results=utf8");
	
	$sql="SELECT *, 
				 DATE_FORMAT(ngay_dang,'%d-%m-%Y') AS ngay FROM mau_tin_rv
		  WHERE giay_phep = 1
				AND DATE_ADD(ngay_dang, INTERVAL thoi_gian_song DAY) > NOW() 
				AND (
						tieu_de LIKE N'%$tim%'
						OR noi_dung LIKE N'%$tim%'
						OR noi_dang LIKE N'%$tim%'
					)
		  ORDER BY vip DESC, ngay_dang DESC";
//		  LIMIT ".$start.", ".$limit;

	$rs=mysql_query($sql);
	
	//echo "<div style='height:50px;'><a href='index.php?noidung=dtrv' class='com fr'>Đăng tin</a></div>";
					
	echo 			"<div class='form'>
						<table width='100%' cellpadding='5' cellspacing='1'>
							<tr class='title_ds' style='font-size:13px'>
								<td>Ngày đăng</td>
								<td>Tiêu đề</td>
								<td>Nơi đăng</td>
							</tr>";		
	
	if(mysql_num_rows($rs) > 0){
		while($row = mysql_fetch_array($rs)){
			$ms_mt =  $row[0];
			$tieu_de = $row[3];
			$ngay_dang = $row['ngay'];
			$noi_dang = $row[6];
			$vip = $row[9];
			$so_lan_xem = $row[10];
			
			echo   "  	<tr align='center'>
							<td>$ngay_dang</td>
							<td align='left'><li><a href='dang_tin_rv/update_so_lan_xem.php?ms=$ms_mt'>$tieu_de</a>($so_lan_xem lượt xem)";
			if($vip==1){
				echo "<b style='color:red'>-VIP-</b>";	
			}
			echo			"</li></td>
							<td>$noi_dang</td>
						</tr>";
		}
	}
	
	echo 				"</table></div>";
?>